using System;
using System.Collections.Generic;
using System.Text;
using System.Timers;
using FlickrControls;
using LoungrCore;

namespace Loungr
{
    public class LoungrManager
    {
        public delegate void ChangeModuleDelegate(object sender, System.Windows.Controls.UserControl module);
        public event ChangeModuleDelegate ChangeModule;

        FlickrViewer flickrViewer;

        ILoungrModule currentModule;

        Timer minorTimer;
        Timer majorTimer;

        public LoungrManager()
        {
            
        }

        public void Intialise()
        {
            flickrViewer = new FlickrViewer();
            flickrViewer.Intialise();
            flickrViewer.ChangeItem();

            if (null != ChangeModule)
            {
                ChangeModule(this, flickrViewer);
            }

            currentModule = flickrViewer;

            minorTimer = new Timer();

            minorTimer.Interval = 30000;
            minorTimer.Elapsed += new ElapsedEventHandler(minorTimer_Elapsed);
            minorTimer.Start();

            majorTimer = new Timer();

            majorTimer.Interval = 1800000;
            majorTimer.Elapsed += new ElapsedEventHandler(majorTimer_Elapsed);
            majorTimer.Start();
        }

        void majorTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        void minorTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            currentModule.ChangeItem();
        }
    }
}
